//
//  SortViewController.m
//  XRSquare
//
//  Created by UaenaMo on 2018/7/26.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "SortViewController.h"
#import "tableViewSelector.h"
#import "JinengSelectViewController.h"
#import "ClassViewController.h"
#import "DistrictViewController.h"
#import "ResultTableViewCell.h"
#import "BiaoQian.h"
#import "BiaoQianSelectViewController.h"
#import "WenZhangTableViewCell.h"

#import "WenZhangViewController.h"
#import "JobDetailViewController.h"
#import "HomeDetailViewController.h"

@interface SortViewController ()<SelectionDelegate,UITableViewDelegate,UITableViewDataSource,jinenngSelectDelegate,classSelectDelegate,distr,UITextFieldDelegate,biaoqianDelegate,BiaoQianSelectViewControllerDelegate,UITextFieldDelegate>
{
    UIButton * typeButton;
    UITextField * textField;
    tableViewSelector * selection;
    int currentSelection;
    
    UIView * indicator;
    UIButton * navSelection1;
    UIButton * navSelection2;
    UIButton * navSelection3;
    UIButton * navSelection4;
    UIButton * navSelection5;

    NSArray * queryLeibie;
    NSArray * queryXingshi;
    NSArray * queryZuzhi;
    NSArray * queryQye;
    NSArray * queryQuyu;
    NSArray * queryShijian;
    NSArray * queryDanwei;
    
    UIView * queryView;
    
    UIButton * queryView3type1;
    UIButton * queryView3type2;
    UIButton * queryView3type3;
    UIButton * queryView3type4;
    UIButton * queryView3type5;
    BiaoQian * biaoQian;
    UIButton * remove;
    UIButton * remove1;

    UITableView * contentTableView;
    
    NSString * leibieData;
    NSString * xingshidata;
    NSString * shijiandata;
    NSString * zuzhidata;
    NSString * quyudata;
    NSString * qiyedata;
    
    NSArray * dataArr;
}
@end

@implementation SortViewController

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
    {
        currentSelection = 1;
        queryQye = @[@{@"string":@"不限",@"value":@"0"},
                     @{@"string":@"国有企业",@"value":@"1"},
                     @{@"string":@"集体企业",@"value":@"2"},
                     @{@"string":@"有限责任公司",@"value":@"3"},
                     @{@"string":@"股份有限公司",@"value":@"4"},
                     @{@"string":@"私营企业",@"value":@"5"},
                     @{@"string":@"中外合资企业",@"value":@"6"},
                     @{@"string":@"外商投资企业",@"value":@"7"},
                     @{@"string":@"事业单位",@"value":@"8"},
                     @{@"string":@"国家机关",@"value":@"9"},
                     @{@"string":@"政府",@"value":@"10"},
                     @{@"string":@"社会团体",@"value":@"11"}
                     ];
        leibieData = @"";
        xingshidata = @"";
        shijiandata = @"";
        zuzhidata = @"";
        quyudata = @"";
        qiyedata = @"";
    }
    return self;
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.tabBarController.tabBar.hidden = NO;
}

-(void)requestData
{
    NSString * text = @"";
    NSString * class = @"";
    
    NSString * classid;
    if (typeButton.selected)
    {
        classid = @"1";
    }
    else
    {
        classid = @"0";
    }
    if (currentSelection == 1)
    {
        NSLog(@"%@ %@ %@ %@",text,class,leibieData,xingshidata);
        
        [NetRequestCenter telentShowwithtaskname:textField.text type:classid classid:leibieData onoffine:xingshidata page:@"1" Result:^(BOOL success, NSDictionary *resultDic) {
            if (success)
            {
                dataArr = [[[resultDic objectForKey:@"data"]objectForKey:@"Detail"]objectForKey:@"content"];
                [contentTableView reloadData];
            }
        }];
    }
    if (currentSelection == 2)
    {
        [NetRequestCenter demandshowwithtaskname:textField.text type:classid classid:leibieData onoffine:xingshidata page:@"1" Result:^(BOOL success, NSDictionary *resultDic) {
            if (success)
            {
                dataArr = [[[resultDic objectForKey:@"data"]objectForKey:@"Detail"]objectForKey:@"content"];
                [contentTableView reloadData];
            }
        }];
    }
    if (currentSelection == 3)
    {
        [NetRequestCenter activitygongyishowwithtaskname:textField.text type:classid classid:leibieData onoffine:xingshidata page:@"1" addressid:quyudata property:qiyedata zuzhixingshi:zuzhidata cityname:[[NSUserDefaults standardUserDefaults]objectForKey:@"city"] Result:^(BOOL success, NSDictionary *resultDic) {
            if (success) {
                dataArr = [[[resultDic objectForKey:@"data"]objectForKey:@"Detail"]objectForKey:@"content"];
                [contentTableView reloadData];
            }
        }];
    }
    if (currentSelection == 4)
    {
        NSMutableArray * att = [NSMutableArray array];
        for ( NSDictionary * dic in biaoQian.output)
        {
            [att addObject:[dic objectForKey:@"LevelId"]];
        }
        
        [NetRequestCenter activityjobwithtaskname:textField.text type:classid classid:leibieData onoffine:xingshidata page:@"1" addressid:quyudata companytaskproperty:shijiandata companyproperty:qiyedata cityname:[[NSUserDefaults standardUserDefaults]objectForKey:@"city"] tagid:att Result:^(BOOL success, NSDictionary *resultDic) {
            if (success) {
                dataArr = [[[resultDic objectForKey:@"data"]objectForKey:@"Detail"]objectForKey:@"content"];
                [contentTableView reloadData];
            }
        }];
    }
    if (currentSelection == 5)
    {
        [NetRequestCenter newswithtype:leibieData age:@"" page:@"1" searchcontent:text result:^(BOOL success, NSDictionary *resultDic) {
            if (success) {
                dataArr = [[[resultDic objectForKey:@"data"]objectForKey:@"Detail"]objectForKey:@"content"];
                [contentTableView reloadData];
            }
        }];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    
    UIView * searchView = [[UIView alloc]initWithFrame:CGRectMake(10, 10 + rectStatus.size.height + rectNav.size.height, ScreenWidth - 20, 30)];
    searchView.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
    searchView.layer.cornerRadius = 4;
    [self.view addSubview:searchView];
    
    typeButton = [[UIButton alloc]initWithFrame:CGRectMake(10, 5, 60, 20)];
    typeButton.backgroundColor = [UIColor orangeColor];
    typeButton.layer.cornerRadius = 3;
    typeButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [typeButton addTarget:self action:@selector(typeAction) forControlEvents:UIControlEventTouchUpInside];
    [searchView addSubview:typeButton];
    
    textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 5, searchView.frame.size.width - 20, 20)];
    textField.placeholder = @"请输入搜索关键字";
    textField.font = [UIFont systemFontOfSize:15];
    textField.returnKeyType = UIReturnKeySearch;
    textField.delegate = self;
    [searchView addSubview:textField];
    
    contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 80 - 44) style:UITableViewStylePlain];
    contentTableView.delegate = self;
    contentTableView.dataSource = self;
    contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:contentTableView];
    
    
    selection = [[tableViewSelector alloc]initWithFrame:CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - 150 - rectStatus.size.height - rectNav.size.height - 44)];
    selection.delegate = self;
    [self.view addSubview:selection];
    selection.hidden = YES;
    
    
    UIView * titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth - 20, 40)];
    
    navSelection1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, titleView.frame.size.width/5, 40)];
    [navSelection1 setTitle:@"技能售卖" forState:UIControlStateNormal];
    navSelection1.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    [navSelection1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navSelection1 setTitleColor:themeColor forState:UIControlStateSelected];
    [navSelection1 addTarget:self action:@selector(selection1) forControlEvents:UIControlEventTouchUpInside];

    navSelection2 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width/5, 0, titleView.frame.size.width/5, 40)];
    [navSelection2 setTitle:@"需求发布" forState:UIControlStateNormal];
    navSelection2.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    [navSelection2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navSelection2 setTitleColor:themeColor forState:UIControlStateSelected];
    [navSelection2 addTarget:self action:@selector(selection2) forControlEvents:UIControlEventTouchUpInside];
    
    navSelection3 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width/5 * 2, 0, titleView.frame.size.width/5, 40)];
    [navSelection3 setTitle:@"公益活动" forState:UIControlStateNormal];
    navSelection3.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    [navSelection3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navSelection3 setTitleColor:themeColor forState:UIControlStateSelected];
    [navSelection3 addTarget:self action:@selector(selection3) forControlEvents:UIControlEventTouchUpInside];
    
    navSelection4 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width/5 * 3, 0, titleView.frame.size.width/5, 40)];
    [navSelection4 setTitle:@"社企实践" forState:UIControlStateNormal];
    navSelection4.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    [navSelection4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navSelection4 setTitleColor:themeColor forState:UIControlStateSelected];
    [navSelection4 addTarget:self action:@selector(selection4) forControlEvents:UIControlEventTouchUpInside];
    
    navSelection5 = [[UIButton alloc]initWithFrame:CGRectMake(titleView.frame.size.width/5 * 4, 0, titleView.frame.size.width/5, 40)];
    [navSelection5 setTitle:@"文章品读" forState:UIControlStateNormal];
    navSelection5.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    [navSelection5 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navSelection5 setTitleColor:themeColor forState:UIControlStateSelected];
    [navSelection5 addTarget:self action:@selector(selection5) forControlEvents:UIControlEventTouchUpInside];
    
    [titleView addSubview:navSelection1];
    [titleView addSubview:navSelection2];
    [titleView addSubview:navSelection3];
    [titleView addSubview:navSelection4];
    [titleView addSubview:navSelection5];
    
    indicator = [[UIView alloc]initWithFrame:CGRectMake(0, 38, 60, 2)];
    indicator.backgroundColor = themeColor;
    [titleView addSubview:indicator];
    
    self.navigationItem.titleView = titleView;
    [self selection1];
}

-(void)refreshContent
{
    [textField resignFirstResponder];

    currentSelection = 1;
    queryQye = @[@{@"string":@"不限",@"value":@"0"},
                 @{@"string":@"国有企业",@"value":@"1"},
                 @{@"string":@"集体企业",@"value":@"2"},
                 @{@"string":@"有限责任公司",@"value":@"3"},
                 @{@"string":@"股份有限公司",@"value":@"4"},
                 @{@"string":@"私营企业",@"value":@"5"},
                 @{@"string":@"中外合资企业",@"value":@"6"},
                 @{@"string":@"外商投资企业",@"value":@"7"},
                 @{@"string":@"事业单位",@"value":@"8"},
                 @{@"string":@"国家机关",@"value":@"9"},
                 @{@"string":@"政府",@"value":@"10"},
                 @{@"string":@"社会团体",@"value":@"11"}
                 ];
    leibieData = @"";
    xingshidata = @"";
    shijiandata = @"";
    zuzhidata = @"";
    quyudata = @"";
    qiyedata = @"";
}

-(void)selection1
{
    [self refreshContent];
    
    currentSelection = 1;
    [typeButton setTitle:@"搜昵称" forState:UIControlStateNormal];
    [typeButton setTitle:@"搜技能" forState:UIControlStateSelected];
    typeButton.hidden = NO;
    textField.frame = CGRectMake(10 + 70, 5, ScreenWidth - 40, 20);
    
    navSelection1.selected = YES;
    navSelection2.selected = NO;
    navSelection3.selected = NO;
    navSelection4.selected = NO;
    navSelection5.selected = NO;

    indicator.center = CGPointMake(navSelection1.center.x, indicator.center.y);
    
    [queryView removeFromSuperview];
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    queryView = [[UIView alloc]initWithFrame:CGRectMake(10, rectStatus.size.height + rectNav.size.height + 40, ScreenWidth, 40)];
    contentTableView.frame = CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 80 - 44);

    {
        queryView3type1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth/5 - 12, 20)];
        queryView3type1.backgroundColor = [UIColor orangeColor];
        queryView3type1.layer.cornerRadius = 4;
        queryView3type1.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
        [queryView3type1 addTarget:self action:@selector(queryLeibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type1];
        
        remove = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.size.width - 7, 3, 15, 15)];
        [remove setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove addTarget:self action:@selector(removeleibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove];
        remove.hidden = YES;

        queryView3type2 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.origin.x + queryView3type1.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type2.backgroundColor = [UIColor orangeColor];
        queryView3type2.layer.cornerRadius = 4;
        queryView3type2.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type2 setTitle:@"形式" forState:UIControlStateNormal];
        [queryView3type2 addTarget:self action:@selector(queryXingshi) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type2];
    }
    [self.view addSubview:queryView];
    
    [self requestData];
}

-(void)selection2
{
    [self refreshContent];

    currentSelection = 2;
    [typeButton setTitle:@"搜昵称" forState:UIControlStateNormal];
    [typeButton setTitle:@"搜技能" forState:UIControlStateSelected];
    typeButton.hidden = NO;
    textField.frame = CGRectMake(10 + 70, 5, ScreenWidth - 40, 20);
    
    navSelection1.selected = NO;
    navSelection2.selected = YES;
    navSelection3.selected = NO;
    navSelection4.selected = NO;
    navSelection5.selected = NO;
    indicator.center = CGPointMake(navSelection2.center.x, indicator.center.y);

    [queryView removeFromSuperview];
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    queryView = [[UIView alloc]initWithFrame:CGRectMake(10, rectStatus.size.height + rectNav.size.height + 40, ScreenWidth, 40)];
    contentTableView.frame = CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 80 - 44);

    {
        queryView3type1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth/5 - 12, 20)];
        queryView3type1.backgroundColor = [UIColor orangeColor];
        queryView3type1.layer.cornerRadius = 4;
        queryView3type1.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
        [queryView3type1 addTarget:self action:@selector(queryLeibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type1];
        
        remove = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.size.width - 7, 3, 15, 15)];
        [remove setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove addTarget:self action:@selector(removeleibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove];
        remove.hidden = YES;

        queryView3type2 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.origin.x + queryView3type1.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type2.backgroundColor = [UIColor orangeColor];
        queryView3type2.layer.cornerRadius = 4;
        queryView3type2.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type2 setTitle:@"形式" forState:UIControlStateNormal];
        [queryView3type2 addTarget:self action:@selector(queryXingshi) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type2];
    }
    [self.view addSubview:queryView];
    [self requestData];

}

-(void)selection3
{
    [self refreshContent];

    currentSelection = 3;
    [typeButton setTitle:@"搜活动" forState:UIControlStateNormal];
    [typeButton setTitle:@"搜主体" forState:UIControlStateSelected];
    typeButton.hidden = NO;
    textField.frame = CGRectMake(10 + 70, 5, ScreenWidth - 40, 20);
    
    navSelection1.selected = NO;
    navSelection2.selected = NO;
    navSelection3.selected = YES;
    navSelection4.selected = NO;
    navSelection5.selected = NO;
    indicator.center = CGPointMake(navSelection3.center.x, indicator.center.y);

    [queryView removeFromSuperview];
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    queryView = [[UIView alloc]initWithFrame:CGRectMake(10, rectStatus.size.height + rectNav.size.height + 40, ScreenWidth, 40)];
    contentTableView.frame = CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 80 - 44);

    {
        queryView3type1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth/5 - 12, 20)];
        queryView3type1.backgroundColor = [UIColor orangeColor];
        queryView3type1.layer.cornerRadius = 4;
        queryView3type1.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
        [queryView3type1 addTarget:self action:@selector(queryLeibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type1];
        
        remove = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.size.width - 7, 3, 15, 15)];
        [remove setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove addTarget:self action:@selector(removeleibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove];
        remove.hidden = YES;

        queryView3type2 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.origin.x + queryView3type1.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type2.backgroundColor = [UIColor orangeColor];
        queryView3type2.layer.cornerRadius = 4;
        queryView3type2.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type2 setTitle:@"形式" forState:UIControlStateNormal];
        [queryView3type2 addTarget:self action:@selector(queryXingshi) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type2];
        
        queryView3type3 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type2.frame.origin.x + queryView3type2.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type3.backgroundColor = [UIColor orangeColor];
        queryView3type3.layer.cornerRadius = 4;
        queryView3type3.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type3 setTitle:@"组织形式" forState:UIControlStateNormal];
        [queryView3type3 addTarget:self action:@selector(queryZuzhi) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type3];
        
        queryView3type4 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type3.frame.origin.x + queryView3type3.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type4.backgroundColor = [UIColor orangeColor];
        queryView3type4.layer.cornerRadius = 4;
        queryView3type4.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type4 setTitle:@"企业性质" forState:UIControlStateNormal];
        [queryView3type4 addTarget:self action:@selector(queryQye) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type4];
        
        queryView3type5 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type4.frame.origin.x + queryView3type4.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type5.backgroundColor = [UIColor orangeColor];
        queryView3type5.layer.cornerRadius = 4;
        queryView3type5.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type5 setTitle:@"区域" forState:UIControlStateNormal];
        [queryView3type5 addTarget:self action:@selector(queryQuyu) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type5];
        
        remove1 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type4.frame.size.width + queryView3type4.frame.origin.x - 7, 3, 15, 15)];
        [remove1 setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove1 addTarget:self action:@selector(removequyu) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove1];
        remove1.hidden = YES;
    }
    [self.view addSubview:queryView];
    [self requestData];

}

-(void)selection4
{
    [self refreshContent];

    currentSelection = 4;
    [typeButton setTitle:@"搜企业" forState:UIControlStateNormal];
    [typeButton setTitle:@"搜实践" forState:UIControlStateSelected];
    typeButton.hidden = NO;
    textField.frame = CGRectMake(10 + 70, 5, ScreenWidth - 40, 20);
    
    navSelection1.selected = NO;
    navSelection2.selected = NO;
    navSelection3.selected = NO;
    navSelection4.selected = YES;
    navSelection5.selected = NO;
    indicator.center = CGPointMake(navSelection4.center.x, indicator.center.y);

    [queryView removeFromSuperview];
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    queryView = [[UIView alloc]initWithFrame:CGRectMake(10, rectStatus.size.height + rectNav.size.height + 40, ScreenWidth, 70)];
    contentTableView.frame = CGRectMake(0, 110 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 110 - 44);
    {
        queryView3type1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth/5 - 12, 20)];
        queryView3type1.backgroundColor = [UIColor orangeColor];
        queryView3type1.layer.cornerRadius = 4;
        queryView3type1.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
        [queryView3type1 addTarget:self action:@selector(queryLeibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type1];
        
        remove = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.size.width - 7, 3, 15, 15)];
        [remove setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove addTarget:self action:@selector(removeleibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove];
        remove.hidden = YES;
        
        queryView3type2 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type1.frame.origin.x + queryView3type1.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type2.backgroundColor = [UIColor orangeColor];
        queryView3type2.layer.cornerRadius = 4;
        queryView3type2.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type2 setTitle:@"形式" forState:UIControlStateNormal];
        [queryView3type2 addTarget:self action:@selector(queryXingshi) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type2];
        
        queryView3type3 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type2.frame.origin.x + queryView3type2.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type3.backgroundColor = [UIColor orangeColor];
        queryView3type3.layer.cornerRadius = 4;
        queryView3type3.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type3 setTitle:@"实践形式" forState:UIControlStateNormal];
        [queryView3type3 addTarget:self action:@selector(queryShijian) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type3];
        
        queryView3type4 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type3.frame.origin.x + queryView3type3.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type4.backgroundColor = [UIColor orangeColor];
        queryView3type4.layer.cornerRadius = 4;
        queryView3type4.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type4 setTitle:@"单位性质" forState:UIControlStateNormal];
        [queryView3type4 addTarget:self action:@selector(queryQye) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type4];
        
        queryView3type5 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type4.frame.origin.x + queryView3type4.frame.size.width + 10, 10, ScreenWidth/5 - 12, 20)];
        queryView3type5.backgroundColor = [UIColor orangeColor];
        queryView3type5.layer.cornerRadius = 4;
        queryView3type5.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type5 setTitle:@"区域" forState:UIControlStateNormal];
        [queryView3type5 addTarget:self action:@selector(queryQuyu) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type5];
        
        remove1 = [[UIButton alloc]initWithFrame:CGRectMake(queryView3type4.frame.size.width + queryView3type4.frame.origin.x - 7, 3, 15, 15)];
        [remove1 setImage:[UIImage imageNamed:@"关闭2-fill"] forState:UIControlStateNormal];
        [remove1 addTarget:self action:@selector(removequyu) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:remove1];
        remove1.hidden = YES;
        
        biaoQian = [[BiaoQian alloc]initWithFrame:CGRectMake(0, 40, ScreenWidth, 30)];
        biaoQian.delegate = self;
        [queryView addSubview:biaoQian];
    }
    [self.view addSubview:queryView];
    [self requestData];

}

-(void)selection5
{
    [self refreshContent];

    currentSelection = 5;
    typeButton.hidden = YES;
    textField.frame = CGRectMake(10, 5, ScreenWidth - 40, 20);

    navSelection1.selected = NO;
    navSelection2.selected = NO;
    navSelection3.selected = NO;
    navSelection4.selected = NO;
    navSelection5.selected = YES;
    indicator.center = CGPointMake(navSelection5.center.x, indicator.center.y);

    [queryView removeFromSuperview];
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;
    queryView = [[UIView alloc]initWithFrame:CGRectMake(10, rectStatus.size.height + rectNav.size.height + 40, ScreenWidth, 40)];
    
    contentTableView.frame = CGRectMake(0, 80 + rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height - 80 - 44);
    {
        queryView3type1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth/5 - 12, 20)];
        queryView3type1.backgroundColor = [UIColor orangeColor];
        queryView3type1.layer.cornerRadius = 4;
        queryView3type1.titleLabel.font = [UIFont systemFontOfSize:13];
        [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
        [queryView3type1 addTarget:self action:@selector(queryLeibie) forControlEvents:UIControlEventTouchUpInside];
        [queryView addSubview:queryView3type1];
    }
    [self.view addSubview:queryView];
    [self requestData];

}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    [self requestData];
    return YES;
}

-(void)addBiaoQian
{
    BiaoQianSelectViewController * select = [[BiaoQianSelectViewController alloc]init];
    select.delegate = self;
    [self.navigationController pushViewController:select animated:YES];
    self.tabBarController.tabBar.hidden = YES;
}

-(void)delBiaoQian
{
    [self requestData];
}

-(void)selectedItem:(NSDictionary *)dic
{
    [biaoQian insertCode:dic];
    [self requestData];
}

-(void)typeAction
{
    [self requestData];
    typeButton.selected = !typeButton.selected;
}

-(void)removequyu
{
    remove1.hidden = YES;
    quyudata = @"";
    [queryView3type5 setTitle:@"区域" forState:UIControlStateNormal];
    [self requestData];
}

-(void)queryLeibie
{
//    selection.hidden = NO;
//    selection.dataArr = queryLeibie;
    if (currentSelection == 1)
    {
        JinengSelectViewController * jienng = [[JinengSelectViewController alloc]init];
        jienng.delegate = self;
        jienng.fack = YES;
        [self.navigationController pushViewController:jienng animated:YES];
    }
    else if (currentSelection == 2)
    {
        JinengSelectViewController * jienng = [[JinengSelectViewController alloc]init];
        jienng.delegate = self;
        jienng.fack = YES;
        [self.navigationController pushViewController:jienng animated:YES];
    }
    else if (currentSelection == 3)
    {
        ClassViewController * select = [[ClassViewController alloc]init];
        select.delegate = self;
        [self.navigationController pushViewController:select animated:YES];
    }
    else if (currentSelection == 4)
    {
        JinengSelectViewController * jienng = [[JinengSelectViewController alloc]init];
        jienng.delegate = self;
        jienng.selectedId = @"10003";
        jienng.fack = YES;
        [self.navigationController pushViewController:jienng animated:YES];
    }
    else
    {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                                 message:nil
                                                                          preferredStyle:UIAlertControllerStyleActionSheet];
        
        UIAlertAction * item1 = [UIAlertAction actionWithTitle:@"不限" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type1 setTitle:@"不限" forState:UIControlStateNormal];
            [self requestData];
        }];
        UIAlertAction * item2 = [UIAlertAction actionWithTitle:@"城市" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type1 setTitle:@"城市" forState:UIControlStateNormal];
            [self requestData];
        }];
        UIAlertAction * item3 = [UIAlertAction actionWithTitle:@"蓄锐故事" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type1 setTitle:@"蓄锐故事" forState:UIControlStateNormal];
            [self requestData];
        }];
        UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        }];
        
        [alertController addAction:item1];
        [alertController addAction:item2];
        [alertController addAction:item3];
        [alertController addAction:cancelAction];
        
        [self presentViewController:alertController animated:YES completion:nil];
    }

}

-(void)removeleibie
{
    remove.hidden = YES;
    leibieData = @"";
    [queryView3type1 setTitle:@"类别" forState:UIControlStateNormal];
    [self requestData];

}

-(void)selectedJineng:(NSString *)jineng jinengid:(NSString *)jinengid
{
    remove.hidden = NO;
    leibieData = jinengid;
    [queryView3type1 setTitle:jineng forState:UIControlStateNormal];
    [self requestData];

}

-(void)selectedClass:(NSString *)classname icd:(NSString *)classid
{
    remove.hidden = NO;
    leibieData = classid;
    [queryView3type1 setTitle:classname forState:UIControlStateNormal];
    [self requestData];

}

-(void)queryXingshi
{
//    selection.hidden = NO;
//    selection.dataArr = queryXingshi;
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                             message:nil
                                                                      preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction * item1 = [UIAlertAction actionWithTitle:@"不限" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type2 setTitle:@"不限" forState:UIControlStateNormal];
        xingshidata = @"";
        [self requestData];

    }];
    UIAlertAction * item2 = [UIAlertAction actionWithTitle:@"线下" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type2 setTitle:@"线下" forState:UIControlStateNormal];
        xingshidata = @"0";
        [self requestData];

    }];
    UIAlertAction * item3 = [UIAlertAction actionWithTitle:@"线上" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type2 setTitle:@"线上" forState:UIControlStateNormal];
        xingshidata = @"1";
        [self requestData];

    }];
    UIAlertAction * item4 = [UIAlertAction actionWithTitle:@"线上/线下" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type2 setTitle:@"线上/线下" forState:UIControlStateNormal];
        xingshidata = @"2";
        [self requestData];

    }];
    UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    [alertController addAction:item1];
    [alertController addAction:item2];
    [alertController addAction:item3];
    [alertController addAction:item4];
    [alertController addAction:cancelAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

-(void)queryZuzhi
{
    selection.hidden = NO;
    selection.dataArr = queryZuzhi;

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                                 message:nil
                                                                          preferredStyle:UIAlertControllerStyleActionSheet];
        
        UIAlertAction * item1 = [UIAlertAction actionWithTitle:@"不限" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type3 setTitle:@"不限" forState:UIControlStateNormal];
            zuzhidata = @"";
            [self requestData];
        }];
        UIAlertAction * item2 = [UIAlertAction actionWithTitle:@"个人" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type3 setTitle:@"个人" forState:UIControlStateNormal];
            zuzhidata = @"0";
            [self requestData];
        }];
        UIAlertAction * item3 = [UIAlertAction actionWithTitle:@"组织/企业" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [queryView3type3 setTitle:@"组织/企业" forState:UIControlStateNormal];
            zuzhidata = @"1";
            [self requestData];
        }];
    
        UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        }];
        
        [alertController addAction:item1];
        [alertController addAction:item2];
        [alertController addAction:item3];
        [alertController addAction:cancelAction];
        
        [self presentViewController:alertController animated:YES completion:nil];
}

-(void)queryQye
{
    selection.hidden = NO;
    selection.dataArr = queryQye;
    
}

-(void)selectedString:(NSString *)string data:(NSDictionary *)data
{
    [queryView3type4 setTitle:string forState:UIControlStateNormal];
    qiyedata = [data objectForKey:@"value"];
    [self requestData];
    
    remove1.hidden = NO;
}

-(void)queryQuyu
{
    DistrictViewController * district = [[DistrictViewController alloc]init];
    district.cityId = @"";
    district.delegate = self;
    [self.navigationController pushViewController:district animated:YES];
}

-(void)selectedDis:(NSString *)dis disid:(NSString *)disid city:(NSString *)city
{
    [queryView3type5 setTitle:dis forState:UIControlStateNormal];
    quyudata = disid;
    [self requestData];

}

-(void)queryShijian
{
    selection.hidden = NO;
    selection.dataArr = queryShijian;
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                             message:nil
                                                                      preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction * item1 = [UIAlertAction actionWithTitle:@"不限" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type3 setTitle:@"不限" forState:UIControlStateNormal];
        shijiandata = @"";
        [self requestData];

    }];
    UIAlertAction * item2 = [UIAlertAction actionWithTitle:@"实习" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type3 setTitle:@"实习" forState:UIControlStateNormal];
        shijiandata = @"0";
        [self requestData];

    }];
    UIAlertAction * item3 = [UIAlertAction actionWithTitle:@"全职" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type3 setTitle:@"全职" forState:UIControlStateNormal];
        shijiandata = @"1";
        [self requestData];

    }];
    UIAlertAction * item4 = [UIAlertAction actionWithTitle:@"兼职" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [queryView3type3 setTitle:@"兼职" forState:UIControlStateNormal];
        shijiandata = @"2";
        [self requestData];

    }];
    UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    [alertController addAction:item1];
    [alertController addAction:item2];
    [alertController addAction:item3];
    [alertController addAction:item4];
    [alertController addAction:cancelAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}


-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [textField resignFirstResponder];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [dataArr count];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (currentSelection == 5) {
        return [WenZhangTableViewCell height];
    }
    else
    {
        if (currentSelection == 1) {
            
        }
        else if (currentSelection == 2)
        {
            
        }
        else if (currentSelection == 3){
            
        }
        return [ResultTableViewCell heightWithType:currentSelection];
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (currentSelection == 5)
    {
        static NSString * identifer = @"cell1";
        WenZhangTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[WenZhangTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        [cell loadData:[dataArr objectAtIndex:indexPath.row]];
        return cell;
    }
    else
    {
        static NSString * identifer = @"cell";
        ResultTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[ResultTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        [cell loadData:[dataArr objectAtIndex:indexPath.row] type:currentSelection];
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    self.tabBarController.tabBar.hidden = YES;
    if (currentSelection == 1)
    {
        JobDetailViewController * job = [[JobDetailViewController alloc]init];
        job.contentid = [[dataArr objectAtIndex:indexPath.row]objectForKey:@"TaskID"];
        job.demand = NO;
        [self.navigationController pushViewController:job animated:YES];
    }
    else if (currentSelection == 2)
    {
        JobDetailViewController * job = [[JobDetailViewController alloc]init];
        job.contentid = [[dataArr objectAtIndex:indexPath.row]objectForKey:@"TaskID"];
        job.demand = YES;
        [self.navigationController pushViewController:job animated:YES];
    }
    else if (currentSelection == 3)
    {
        HomeDetailViewController * job = [[HomeDetailViewController alloc]init];
        job.contentid = [[dataArr objectAtIndex:indexPath.row]objectForKey:@"TaskID"];
        [self.navigationController pushViewController:job animated:YES];
    }
    else if (currentSelection == 4)
    {
        HomeDetailViewController * job = [[HomeDetailViewController alloc]init];
        job.contentid = [[dataArr objectAtIndex:indexPath.row]objectForKey:@"TaskID"];
        [self.navigationController pushViewController:job animated:YES];
    }
    else
    {
        WenZhangViewController * wenzhang = [[WenZhangViewController alloc]init];
        wenzhang.contentId = [[dataArr objectAtIndex:indexPath.row] objectForKey:@"Id"];
        [self.navigationController pushViewController:wenzhang animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
